package com.huifaapp.mall.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.google.gson.Gson;
import com.huifaapp.mall.R;
import com.huifaapp.mall.afinal.JSConstants;
import com.huifaapp.mall.api.ApiManager;
import com.huifaapp.mall.base.activity.BaseActivity;
import com.huifaapp.mall.base.basemvp.IPresenter;
import com.huifaapp.mall.bean.UsersPayDefult;
import com.huifaapp.mall.bean.jdHtml;
import com.huifaapp.mall.dialogs.LoadingDialog;

import com.huifaapp.mall.js.AndroidInterface;
import com.huifaapp.mall.uitils.AppManager;
import com.just.library.AgentWeb;
import com.just.library.ChromeClientCallbackManager;
import com.squareup.okhttp.Request;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;

/**
 * Created by Administrator on 2017-10-24.
 */

public class HtmlActivity extends AppCompatActivity {
    private WebView ll_web_container;
    private String url,title;
    private ImageView iv_html_back;
    private TextView tv_html_tilte;
    private LinearLayout ll_html;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jd_html);
        Log.v("shiran","-------------WEBACTIVITY-----------------");

        ll_web_container = (WebView) findViewById(R.id.ll_container);
        iv_html_back= (ImageView) findViewById(R.id.iv_html_back);
        tv_html_tilte= (TextView) findViewById(R.id.tv_html_tilte);
        ll_html= (LinearLayout) findViewById(R.id.ll_html);
        ll_html.setVisibility(View.GONE);
        url = getIntent().getStringExtra("data");
        title=getIntent().getStringExtra("title");
        tv_html_tilte.setText(title+"");
        Log.e("TAF", url +"-----------------------------");
        ll_web_container.loadUrl(url);
        ll_web_container.getSettings().setJavaScriptEnabled(true);
        WebviewSettingsinit();
    }

    private void WebviewSettingsinit() {
        ll_web_container.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return super.shouldOverrideUrlLoading(view, url);

            }
        });
        ll_web_container.setWebViewClient(new WebViewClient() {

            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                handler.proceed();
            }
        });

    }

}
